#include <highgui.h>
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include "opencv2/video/video.hpp"
#include "iostream"
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    QObject::connect(&mCapture,SIGNAL(image_event()),this,SLOT(ShowImage()));
}

MainWindow::~MainWindow()
{
    delete ui;
}

void MainWindow::on_camera_open_btn_clicked()
{
    mCapture.open_device(0);
    mCapture.start();
}

void MainWindow::on_start_cali_btn_clicked()
{

}

void MainWindow::on_save_params_btn_clicked()
{

}

void MainWindow::ShowImage() {
    cv::Mat ImageShow = mCapture.ImgBuf;
    cv::Mat rgb_image;
    cv::cvtColor(ImageShow, rgb_image, cv::COLOR_BGR2RGB);
    ui->Image_label->setPixmap(
                QPixmap::fromImage(QImage((unsigned char*) rgb_image.data, rgb_image.cols, rgb_image.rows, QImage::Format_RGB888)));

}